package com.ysx.exception;

import com.ysx.common.pojo.Result;
import com.ysx.common.pojo.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result exceptionHandler(Exception e) {
        //e.printStackTrace();
        log.error("发生系统异常，具体信息：",e);
        return Result.error();
    }

    @ExceptionHandler(ToutiaoException.class)
    public Result exceptionHandler(ToutiaoException t) {
       // t.printStackTrace();
        log.error("发生异常了，具体信息：",t);
        return Result.errorMessage(t.getMessage(), StatusCode.CUSTOM_FAILURE.code(),null);
    }
}
